import time 
from greenlet import greenlet

# greenlet是yield的在封装

def song():
    while True:
        print('[+]songing')
        g2.switch()
        time.sleep(0.5)
      

def dance():
    while True:
        print('[+]dacneing')
        g1.switch()
        time.sleep(0.5)
        

g1 = greenlet(song)
g2 = greenlet(dance)

# 调用谁就启动谁
g1.switch()
# g2.switch()
